#ifndef MEEGIMSETTINGS_H
#define MEEGIMSETTINGS_H

#include "mysettings.h"
#include "accountsitemmodel.h"
#include "accountslistmodel.h"

#include "QXmppConfiguration.h"

#include <QtDeclarative>

class MeegIMSettings : public MySettings
{
    Q_OBJECT
    Q_DISABLE_COPY( MeegIMSettings )

    Q_PROPERTY( AccountsListModel* accounts READ getAccounts NOTIFY accountsListChanged )

    Q_PROPERTY( QString soundIncomingMessage READ getSoundIncomingMessage WRITE setSoundIncomingMessage NOTIFY soundIncomingMessageChanged )
    Q_PROPERTY( QString soundOutcomingMessage READ getSoundOutcomingMessage WRITE setSoundOutcomingMessage NOTIFY soundOutcomingMessageChanged )

    Q_PROPERTY( bool notifyConnection READ _getNotifyConnection WRITE _setNotifyConnection NOTIFY notifyConnectionChanged )
    Q_PROPERTY( bool notifyOnline READ _getNotifyOnline WRITE _setNotifyOnline NOTIFY notifyOnlineChanged )
    Q_PROPERTY( bool notifyOffline READ _getNotifyOffline WRITE _setNotifyOffline NOTIFY notifyOfflineChanged )
    Q_PROPERTY( bool notifyMessage READ _getNotifyMessage WRITE _setNotifyMessage NOTIFY notifyMessageChanged )
    Q_PROPERTY( bool notifyTyping READ _getNotifyTyping WRITE _setNotifyTyping NOTIFY notifyTypingChanged )

    Q_PROPERTY( QString soundBuddyLogsIn READ getSoundBuddyLogsIn WRITE setSoundBuddyLogsIn NOTIFY soundBuddyLogsInChanged )
    Q_PROPERTY( QString soundBuddyLogsOut READ getSoundBuddyLogsOut WRITE setSoundBuddyLogsOut NOTIFY soundBuddyLogsOutChanged )

    Q_PROPERTY( bool reconnectWhenError READ _getReconnectWhenError WRITE _setReconnectWhenError NOTIFY reconnectWhenErrorChanged )
    Q_PROPERTY( int keepAliveInterval READ _getKeepAliveInterval WRITE _setKeepAliveInterval NOTIFY keepAliveIntervalChanged )

    Q_PROPERTY( QString soundChatSomeoneSaysMyName READ getChatSomeoneSaysMyName WRITE setChatSomeoneSaysMyName NOTIFY soundChatSomeoneSaysMyNameChanged )
    Q_PROPERTY( QString soundChatPersonEnters READ getChatPersonEnters WRITE setChatPersonEnters NOTIFY soundChatPersonEntersChanged )
    Q_PROPERTY( QString soundChatPersonLeaves READ getChatPersonLeaves WRITE setChatPersonLeaves NOTIFY soundChatPersonLeavesChanged )
    Q_PROPERTY( QString soundChatITalk READ getChatITalk WRITE setChatITalk NOTIFY soundChatITalkChanged )
    Q_PROPERTY( QString soundChatOthersTalk READ getChatOthersTalk WRITE setChatOthersTalk NOTIFY soundChatOthersTalkChanged )

    Q_PROPERTY( bool vibrationMessageReceived READ vibrationMessageRecv WRITE setVibrationMessageRecv /*NOTIFY vibrationMessageReceivedChanged*/ )
    Q_PROPERTY( bool vibrationMessageSent READ vibrationMessageSent WRITE setVibrationMessageSent /*NOTIFY vibrationMessageReceivedChanged*/ )
    Q_PROPERTY( bool vibrationChatSomeoneSaysMyName READ vibrationChatSaysMyName WRITE setVibrationChatSaysMyName /*NOTIFY vibrationMessageReceivedChanged*/ )
    Q_PROPERTY( bool vibrationChatOthersTalk READ vibrationChatOthersTalk WRITE setVibrationChatOthersTalk /*NOTIFY vibrationMessageReceivedChanged*/ )

    Q_PROPERTY( QString smilesTheme READ getSmilesTheme WRITE setSmilesTheme NOTIFY smilesThemeChanged )

    AccountsListModel *alm;

    QString jid_indx0;
    QString pass_indx0;
    bool dflt_indx0;

public:
    explicit MeegIMSettings();

    QXmppConfiguration getDefaultAccount();

    Q_INVOKABLE void initListOfAccounts();
    Q_INVOKABLE void setAccount( QString _jid, QString _pass, bool isDflt, QString _resource = "", QString _host = "", QString _port = "", bool manuallyHostPort = false );
    Q_INVOKABLE void removeAccount( QString _jid );
    Q_INVOKABLE void saveStatusText( QString statusText );

    /* для списка аккаунтов */
    Q_INVOKABLE QString getJid_indx0() { return jid_indx0; }
    Q_INVOKABLE QString getPass_indx0() { return pass_indx0; }
    Q_INVOKABLE bool getDef_indx0() { return dflt_indx0; }

    Q_INVOKABLE bool accIsDefault( int index );
    Q_INVOKABLE QString accGetJid( int index );
    Q_INVOKABLE QString accGetPassword( int index );
    Q_INVOKABLE QString accGetResource( int index );
    Q_INVOKABLE QString accGetHost( int index );
    Q_INVOKABLE int accGetPort( int index );
    Q_INVOKABLE bool accIsManuallyHostPort( int index );

    AccountsListModel* getAccounts() const { return alm; }

    /*----------( getter/setter )----------*/

    /* sound of incoming msg */
    QString getSoundIncomingMessage() { return this->getSndIncomingMsg(); }
    void setSoundIncomingMessage( const QString &filePath );

    /* sound of incoming msg */
    QString getSoundOutcomingMessage() { return this->getSndOutcomingMsg(); }
    void setSoundOutcomingMessage( const QString &filePath );

    /* notify when it is doing connection */
    bool _getNotifyConnection() { return this->notifyConnection(); }
    void _setNotifyConnection( bool isSet );

    /* notify when it became online */
    bool _getNotifyOnline() { return this->notifyOnline(); }
    void _setNotifyOnline( bool isSet );

    /* notify when it became offline */
    bool _getNotifyOffline() { return this->notifyOffline(); }
    void _setNotifyOffline( bool isSet );

    /* notify when it received a message */
    bool _getNotifyMessage() { return this->notifyMessage(); }
    void _setNotifyMessage( bool isSet );

    /*  */
    bool _getNotifyTyping() { return this->notifyTyping(); }
    void _setNotifyTyping( bool isSet );

    QString getSoundBuddyLogsIn() { return this->getSndBuddyLogsIn(); }
    void setSoundBuddyLogsIn( const QString &filePath );

    QString getSoundBuddyLogsOut() { return this->getSndBuddyLogsOut(); }
    void setSoundBuddyLogsOut( const QString &filePath );

    bool _getReconnectWhenError() { return this->reconnectWhenError(); }
    void _setReconnectWhenError(bool arg);

    int _getKeepAliveInterval() { return this->keepAliveInterval(); }
    void _setKeepAliveInterval(int arg);

    QString getChatSomeoneSaysMyName() { return this->getSndChatSaysMyName(); }
    void setChatSomeoneSaysMyName( const QString &file);

    QString getChatPersonEnters() { return this->getSndChatPersonEnters(); }
    void setChatPersonEnters( const QString &file );

    QString getChatPersonLeaves() { return this->getSndChatPersonLeaves(); }
    void setChatPersonLeaves( const QString &file );

    QString getChatITalk() { return this->getSndChatITalk(); }
    void setChatITalk( const QString &file );

    QString getChatOthersTalk() { return this->getSndChatOthersTalk(); }
    void setChatOthersTalk( const QString &file );


signals:
    void accountsListChanged();

    void soundIncomingMessageChanged();
    void soundOutcomingMessageChanged();

    void notifyConnectionChanged();
    void notifyOnlineChanged();
    void notifyOfflineChanged();
    void notifyMessageChanged();
    void notifyTypingChanged();
    void soundBuddyLogsInChanged();
    void soundBuddyLogsOutChanged();
    void reconnectWhenErrorChanged();
    void keepAliveIntervalChanged();
    void soundChatSomeoneSaysMyNameChanged();
    void soundChatPersonEntersChanged();
    void soundChatPersonLeavesChanged();
    void soundChatITalkChanged();
    void soundChatOthersTalkChanged();
    void smilesThemeChanged();
};

QML_DECLARE_TYPE( MeegIMSettings )

#endif // MEEGIMSETTINGS_H
